class AlbumEntity {
  String? id;
  String? name;
  String? cover;
  int? sort;
  int? imgCount;
  int? collectionCount;
  String? uid;
  String? username;
  String? avatar;

  // 构造函数
  AlbumEntity({
    this.id,
    this.name,
    this.cover,
    this.sort,
    this.imgCount,
    this.collectionCount,
    this.uid,
    this.username,
    this.avatar,
  });
  // toJson方法
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'cover': cover,
      'sort': sort,
      'imgCount': imgCount,
      'collectionCount': collectionCount,
      'uid': uid,
      'username': username,
      'avatar': avatar,
    };
  }
  // fromJson工厂方法
  factory AlbumEntity.fromJson(Map<String, dynamic> json) {

    return AlbumEntity(
      id: json['id'],
      name: json['name'],
      cover: json['cover'],
      sort: json['sort'] != null ? int.parse(json['sort']) : null,
      imgCount: json['imgCount'] != null ? int.parse(json['imgCount']) : null,
      collectionCount: json['collectionCount'] != null ? int.parse(json['collectionCount']) : null,
      uid: json['uid'],
      username: json['username'],
      avatar: json['avatar'],
    );
  }
}
